#include<sstream>
#include<vector>
#include<map>
#include <iostream>
#include <fstream>
using namespace std;

template <class T>
string GetNextToken(T &in)
{
    char c;
    string ans="";
    c=in.get();
    while(!isalpha(c) && !in.eof())//cleaning non letter charachters
    {
        c=in.get();
    }
    while(isalpha(c) && !in.eof())
    {
        ans.push_back(tolower(c));
        c=in.get();
    }
    return ans;
}
template <class T>
string GetNextToken(T &in, ofstream &out)
{
    char c;
    string ans="";
    c=in.get();
    while(!isalpha(c) && !in.eof())
    {
        out<<(char)c;
        c=in.get();
    }
    while(isalpha(c))
    {
        ans.push_back(tolower(c));
        c=in.get();
    }
    out<<(char)c;
    return ans;
}

void GetMap(char* fileName, map<string,int> &hmap)
{
    ifstream fin(fileName);
    string s;
    string empty ="";
    while((s=GetNextToken(fin))!=empty )
	{
            ++hmap[s];
	}
}

vector<string> GetAllFileLines(char* fileName)
{
    ifstream inputStream;
    inputStream.open(fileName ,ios::binary);
    string line;
    vector<string> store;
    if (inputStream.is_open())
	{
		while (!inputStream.eof())
		{
			getline (inputStream, line);
			store.push_back(line);
		}
    }
    inputStream.close();
    return store;
}
